/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package program.beans;

import java.util.Vector;

/**
 * Beans class to represent a category with id and description as attributes
 * 
 * Responsible: Patrick
 */
public class Category {
    
    private int id;
    private String description;

    public Category(int id, String description) {
        this.id = id;
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
    
    /**
     * Check if current category is in delivered vector
     * 
     * @param catList vector
     * @return true if current category is in delivered vector
     */
    public boolean isIn(Vector<Category> catList) {
        for (Category c : catList) {
            if (c.getId() == this.getId()) {
                return true;
            }
        }
        return false;
    }

    @Override
    public String toString() {
        return description;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Category other = (Category) obj;
        if (this.id != other.id) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 17 * hash + this.id;
        return hash;
    }
    
    
}